<?php
class FriendController extends LBController
{
    public function addAction()
    {/*{{{*/
        $userId = $this->getUserId();

        $friendId = filter_var($this->getParam('u', ''), FILTER_VALIDATE_INT);

        $frd = new Friend();
        $frd->add($userId, $friendId);

        $this->render();
    }/*}}}*/

    public function acceptAction()
    {/*{{{*/
        $userId = $this->getUserId();

        $friendId = filter_var($this->getParam('u', ''), FILTER_VALIDATE_INT);

        $frd = new Friend();
        $frd->accept($userId, $friendId);

        $this->render();
    }/*}}}*/

    public function denyAction()
    {/*{{{*/
        $userId = $this->getUserId();

        $friendId = filter_var($this->getParam('u', ''), FILTER_VALIDATE_INT);

        $frd = new Friend();
        $frd->deny($userId, $friendId);

        $this->render();
    }/*}}}*/

    public function removeAction()
    {/*{{{*/
        $userId = $this->getUserId();

        $friendId = filter_var($this->getParam('uid', ''), FILTER_VALIDATE_INT);

        $frd = new Friend();
        $frd->remove($userId, $friendId);

        $this->render();
    }/*}}}*/

    public function listAction()
    {/*{{{*/
        $userId = $this->getUserId();

        $frd = new Friend();
        $friends = $frd->getFriends($userId);
        $this->assign('friends', $frd->getFriends($userId));

        $this->render();
    }/*}}}*/

    public function requestAction()
    {/*{{{*/
        $userId = $this->getUserId();

        $frd = new Friend();
        $this->assign('requests', $frd->getFriendRequests($userId));
        $this->assign('skipSiderBar', true);

        $this->render();
    }/*}}}*/

    public function previewInviteAction()
    {/*{{{*/
        $userName = $this->getParam('name');
        $email = $this->getParam('email');

        $this->assign('userName', $userName);
        $this->assign('email', $email);
    }/*}}}*/

    public function inviteAction()
    {
        $this->assign('msg', gettext('succ'));
        //TODO:
        //impl
        $this->render('ajax/response', null, true);
    }
}
